package Enums;

public enum UserLevel {
    ADMINISTRATOR(0),
    MANAGEMENT(1),
    BREW_STAFF(2),
    BUSINESS_STAFF(3),
    TAPROOM_STAFF(4);
    
    private int level;

    UserLevel(final int level) {
        this.level = level;
    }

    public int getLevel() {
        return level;
    }

    public static UserLevel getLevel(final String level) {
        return getLevel(Integer.parseInt(level));
    }
    
    public static UserLevel getLevel(final int level) {
        switch (level) {
        case 0:
            return ADMINISTRATOR;
        case 1:
            return MANAGEMENT;
        case 2:
            return BREW_STAFF;
        case 3:
            return BUSINESS_STAFF;
        case 4:
            return TAPROOM_STAFF;
        default:
            throw new EnumConstantNotPresentException(UserLevel.class, String.valueOf(level));
        }
    }
    
    public static UserLevel getLevelByName(final String str) {
        if(str.equals("ADMINISTRATOR")){
            return ADMINISTRATOR;
        } else if(str.equals("MANAGEMENT")){
            return MANAGEMENT;
        } else if(str.equals("BREW_STAFF")){
            return BREW_STAFF;
        } else if(str.equals("BUSINESS_STAFF")){
            return BUSINESS_STAFF;
        } else {
            return TAPROOM_STAFF;
        }
    }
}
